using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpgradeDoubleTrigger:Upgrade {

	bool previousTriggerDown;
	float cooldownRemainingCollected;

	public override void Update(object sender,WeaponEventArgs e) {
		base.Update(sender,e);
		if(weaponWeapon.fireMode!=FireMode.Single) return;
		if(!weapon.isTriggerHeld&&previousTriggerDown) {
			float cooldownRemaining = weaponWeapon.currentBurst.cooldownTime-weaponWeapon.state.timeAfterBurst;
			if(cooldownRemaining<0) cooldownRemaining=0;
			cooldownRemainingCollected=cooldownRemaining;
			weaponWeapon.StartBurst();
		}

		previousTriggerDown=weapon.isTriggerHeld;
	}
	protected override void BurstDecidingEventHandler(object _sender,BurstDecidingEventArgs e) {
		base.BurstDecidingEventHandler(_sender,e);
		if(cooldownRemainingCollected<=0) return;
		e.stat.cooldownTime.AddAdd(cooldownRemainingCollected*0.6f,100000);
	}

}
